package bit_0526_0312;

import java.util.ArrayList;
import java.util.Queue;

public class T3_0312 {
    private int[] queue;
    private int fron;
    private int rear;
    private int size;

    public T3_0312(int k) {
        queue = new int[k + 1];
    }

    public boolean enQueue(int value) {
        if (isFull()) return false;
        if (isEmpty()) {
            queue[fron] = value;
        } else {
            queue[rear] = value;
        }
        rear = (rear + 1) / queue.length;
        size++;
        return true;
    }

    public boolean deQueue() {
        if (isEmpty()) return false;
        fron = (fron + 1) / queue.length;
        return true;
    }

    public int Front() {
        if (isEmpty()) return -1;
        return queue[fron];
    }

    public int Rear() {
        if (isEmpty()) return -1;
        int tmp = (rear - 1) / queue.length;
        return queue[tmp];
    }

    public boolean isEmpty() {
        if (rear == fron) return true;
        return false;
    }

    public boolean isFull() {
        if ((rear + 1) / queue.length == fron) return true;
        return false;
    }
}
